<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<h2>
  Logging configuration
  <button mat-raised-button type="button" class="go-to-dashboard" aria-label="Go to Logging dashboard" [routerLink]="'../'">
    Go to Logging dashboard
  </button>
</h2>

<gio-banner-info class="logging-banner">
  <span>
    Use logging with caution and only for development purposes. It requires more space for analytics storage and can impact API performance.
  </span>
</gio-banner-info>

<form *ngIf="logsConfigurationForm" [formGroup]="logsConfigurationForm" autocomplete="off">
  <mat-card class="logging-card">
    <mat-card-content>
      <!-- Enable health-check -->
      <gio-form-slide-toggle class="logging-card__enable-toggle">
        <gio-form-label>Enable Logging</gio-form-label>
        <mat-slide-toggle
          gioFormSlideToggle
          formControlName="enabled"
          aria-label="Logging enable toggle"
          name="enableLogging"
        ></mat-slide-toggle>
      </gio-form-slide-toggle>

      <mat-divider></mat-divider>

      <div class="logging-card__logging-modes">
        <h4>Logging Mode</h4>
        <gio-form-selection-inline class="logging-card__logging-modes__card-group" [formControl]="mode">
          <gio-form-selection-inline-card *ngFor="let loggingMode of loggingModes" [value]="loggingMode.id">
            <gio-form-selection-inline-card-content [icon]="loggingMode.icon">
              <gio-card-content-title>{{ loggingMode.title }}</gio-card-content-title>
              <gio-card-content-subtitle>{{ loggingMode.description }}</gio-card-content-subtitle>
            </gio-form-selection-inline-card-content>
          </gio-form-selection-inline-card>
        </gio-form-selection-inline>
      </div>

      <div class="logging-card__content-modes">
        <h4>Content Mode</h4>
        <gio-form-selection-inline class="logging-card__content-modes__card-group" [formControl]="content">
          <gio-form-selection-inline-card *ngFor="let contentMode of contentModes" [value]="contentMode.id">
            <gio-form-selection-inline-card-content [icon]="contentMode.icon">
              <gio-card-content-title>{{ contentMode.title }}</gio-card-content-title>
              <gio-card-content-subtitle>{{ contentMode.description }}</gio-card-content-subtitle>
            </gio-form-selection-inline-card-content>
          </gio-form-selection-inline-card>
        </gio-form-selection-inline>
      </div>

      <div class="logging-card__scope-modes">
        <h4>Scope Mode</h4>
        <gio-form-selection-inline class="logging-card__scope-modes__card-group" [formControl]="scope">
          <gio-form-selection-inline-card *ngFor="let scopeMode of scopeModes" [value]="scopeMode.id">
            <gio-form-selection-inline-card-content [icon]="scopeMode.icon">
              <gio-card-content-title>{{ scopeMode.title }}</gio-card-content-title>
              <gio-card-content-subtitle>{{ scopeMode.description }}</gio-card-content-subtitle>
            </gio-form-selection-inline-card-content>
          </gio-form-selection-inline-card>
        </gio-form-selection-inline>
      </div>

      <mat-form-field class="logging-card__conditionEL__form-field">
        <mat-label>Condition</mat-label>
        <input type="text" matInput aria-label="Logging configuration condition" formControlName="condition" />
        <mat-hint> Support EL (e.g: &#123;#request.headers['Content-Type'][0] === 'application/json'&#125; )</mat-hint>
      </mat-form-field>
    </mat-card-content>
  </mat-card>

  <gio-save-bar [form]="logsConfigurationForm" (resetClicked)="ngOnInit()" (submitted)="onSubmit()"></gio-save-bar>
</form>
